package cn.tedu.reflection;

import java.util.Objects;

/***/
public class reviewObject {
    public static void main(String[] args) {
        Preson p1=new Preson("yuanyuan",17,1,"成都");
        Preson p2=new Preson("yuanyuan",17,1,"成都");
        System.out.println(p1.hashCode());
        System.out.println(p2.hashCode());
        System.out.println(p1 ==p2);
        System.out.println(p1.equals(p2));

    }
}
class Preson{
    String name;
    int age;
    int sno;
    String addr;

    public Preson(String name, int age, int sno, String addr) {
        this.name = name;
        this.age = age;
        this.sno = sno;
        this.addr = addr;
    }

    @Override
    public String toString() {
        return "Preson{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sno=" + sno +
                ", addr='" + addr + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Preson preson = (Preson) o;
        return age == preson.age && sno == preson.sno && Objects.equals(name, preson.name) && Objects.equals(addr, preson.addr);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, sno, addr);
    }
}